@using Microsoft.AspNetCore.Components.RenderTree
<div id="test-selector">
  Select test:
    <select bind=@SelectedComponentTypeName>
        <option value="none">Choose...</option>
        <option value="BasicTestApp.InteropComponent">Interop component</option>
        <option value="BasicTestApp.AsyncEventHandlerComponent">Async event handlers</option>
        <option value="BasicTestApp.AddRemoveChildComponents">Add/remove child components</option>
        <option value="BasicTestApp.CounterComponent">Counter</option>
        <option value="BasicTestApp.CounterComponentUsingChild">Counter using child component</option>
        <option value="BasicTestApp.CounterComponentWrapper">Counter wrapped in parent</option>
        <option value="BasicTestApp.FocusEventComponent">Focus events</option>
        <option value="BasicTestApp.KeyPressEventComponent">Key press event</option>
        <option value="BasicTestApp.MouseEventComponent">Mouse events</option>
        <option value="BasicTestApp.TouchEventComponent">Touch events</option>
        <option value="BasicTestApp.InputEventComponent">Input events</option>
        <option value="BasicTestApp.ParentChildComponent">Parent component with child</option>
        <option value="BasicTestApp.PropertiesChangedHandlerParent">Parent component that changes parameters on child</option>
        <option value="BasicTestApp.RedTextComponent">Red text</option>
        <option value="BasicTestApp.RenderFragmentToggler">Render fragment renderer</option>
        <option value="BasicTestApp.TextOnlyComponent">Plain text</option>
        <option value="BasicTestApp.MarkupBlockComponent">Markup blocks</option>
        <option value="BasicTestApp.HierarchicalImportsTest.Subdir.ComponentUsingImports">Imports statement</option>
        <option value="BasicTestApp.HttpClientTest.HttpRequestsComponent">HttpClient tester</option>
        <option value="BasicTestApp.HttpClientTest.BinaryHttpRequestsComponent">Binary HttpClient tester</option>
        <option value="BasicTestApp.HttpClientTest.CookieCounterComponent">HttpClient cookies</option>
        <option value="BasicTestApp.BindCasesComponent">bind cases</option>
        <option value="BasicTestApp.DataDashComponent">data-* attribute rendering</option>
        <option value="BasicTestApp.ExternalContentPackage">External content package</option>
        <option value="BasicTestApp.SvgComponent">SVG</option>
        <option value="BasicTestApp.SvgWithChildComponent">SVG with child component</option>
        <option value="BasicTestApp.LogicalElementInsertionCases">Logical element insertion cases</option>
        <option value="BasicTestApp.ElementRefComponent">Element ref component</option>
        <option value="BasicTestApp.ComponentRefComponent">Component ref component</option>
        <option value="BasicTestApp.AfterRenderInteropComponent">After-render interop component</option>
        <option value="BasicTestApp.EventCasesComponent">Event cases</option>
        <option value="BasicTestApp.EventBubblingComponent">Event bubbling</option>
        <option value="BasicTestApp.EventPreventDefaultComponent">Event preventDefault</option>
        <option value="BasicTestApp.RouterTest.TestRouter">Router</option>
        <option value="BasicTestApp.HtmlBlockChildContent">ChildContent HTML Block</option>
        <option value="BasicTestApp.HtmlMixedChildContent">ChildContent Mixed Block</option>
        <option value="BasicTestApp.HtmlEncodedChildContent">ChildContent HTML Encoded Block</option>
        <option value="BasicTestApp.RazorTemplates">Razor Templates</option>
        <option value="BasicTestApp.MultipleChildContent">Multiple child content</option>
        <option value="BasicTestApp.CascadingValueTest.CascadingValueSupplier">Cascading values</option>
        <option value="BasicTestApp.ConcurrentRenderParent">Concurrent rendering</option>
    </select>

  @if (SelectedComponentType != null)
  {
    <span id="source-info"><code><tt>@(SelectedComponentType.Name.Replace(".", "/")).cshtml</tt></code></span>
  }
  <hr />
</div>

<app>
    @((RenderFragment)RenderSelectedComponent)
</app>

@functions {
    string SelectedComponentTypeName { get; set; } = "none";

    Type SelectedComponentType
        => SelectedComponentTypeName == "none" ? null : Type.GetType(SelectedComponentTypeName);

    void RenderSelectedComponent(RenderTreeBuilder builder)
    {
        if (SelectedComponentType != null)
        {
            builder.OpenComponent(0, SelectedComponentType);
            builder.CloseComponent();
        }
    }
}
